package com.xiashitech.agent.instrumentation.spring.controller;

import com.xiashitech.agent.dto.UserRequest;
import io.opentelemetry.javaagent.shaded.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.GlobalOpenTelemetry;

public class XSSpringControllerSingletons {
    private XSSpringControllerSingletons() {}
    private static final String INSTRUMENTATION_NAME = "com.xiashitech.spring-controller";
    private static final String SPAN_NAME = "xs.spring-controller-span";
    private static final Instrumenter<UserRequest, Void> CONTROLLER_INSTRUMENTER;
    public static Instrumenter<UserRequest, Void> controllerInstrumenter() {
        return CONTROLLER_INSTRUMENTER;
    }

    static {
        CONTROLLER_INSTRUMENTER =
                Instrumenter.<UserRequest, Void>builder(
                                GlobalOpenTelemetry.get(),
                                INSTRUMENTATION_NAME,
                                request -> SPAN_NAME
                        ).addAttributesExtractor(new XSControllerRequestAttributesExtractor()).buildInstrumenter();
    }
}
